package cn.cdqf.zuul.filter;

import cn.cdqf.global.kafka.KafkaReceiver;
import cn.cdqf.global.kafka.KafkaSender;
import cn.cdqf.global.service.MailService;
import com.netflix.zuul.exception.ZuulException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class LoginFilter extends AbstractPreZuulFilter {

    @Autowired
    private MailService mailService;
    @Autowired
    private KafkaSender kafkaSender;
    @Value("${dev.name}")
    private String name;

    @Override
    public int filterOrder() {
        return 2;
    }

    @Override
    public Object run() throws ZuulException {
        log.info("获得对象"+mailService);

        log.info("获得卡夫卡对象："+kafkaSender);
        kafkaSender.sendMessage("cdqf","thank you kafka ok 啦");

        log.info("登录login来了" + name);
        return fail(701,"login fail");
    }
}
